﻿using System.Collections.ObjectModel;
using System.Threading;

namespace SolutionUsingThreadsInModel.Model
{
    public class ThousandsOfElementsInUIModel : BusinessModelBase
    {
        public ObservableCollection<SmallItemModel> SmallItems { get; set; }

        public ThousandsOfElementsInUIModel()
        {
            SmallItems = new ObservableCollection<SmallItemModel>();
        }

        public void CreateSmallItems()
        {
            new Thread(() =>
                       {
                           for (int i = 0; i < 10000; i++)
                           {
                               SmallItems.Add(new SmallItemModel());
                               Thread.Sleep(10);
                           }
                       }).Start();
        }
    }
}
